package controllers

import (
	"github.com/goravel/framework/contracts/http"
)

type BaseController struct {
}

func (c *BaseController) GetPaginationParams(ctx http.Context) (int, int) {
	defaultPage := 1
	defaultPerPage := 10
	maxPerPage := 100

	page := ctx.Request().QueryInt("page", defaultPage)
	perPage := ctx.Request().QueryInt("per_page", defaultPerPage)

	if page < 1 {
		page = defaultPage
	}
	if perPage < 1 || perPage > maxPerPage {
		perPage = defaultPerPage
	}

	return page, perPage
}
